﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace TestApplication
{
    public partial class MainForm : Form
    {
        SingleInstance_MainForm _singleInstanceForm;
        MultiInstance_MainForm _multiInstanceForm;
        public MainForm()
        {
            InitializeComponent();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            if (_singleInstanceForm == null)
            {
                _singleInstanceForm = new SingleInstance_MainForm();
                _singleInstanceForm.Disposed += new EventHandler(_singleInstanceForm_Disposed);
            }
            _singleInstanceForm.Show();
        }

        void _singleInstanceForm_Disposed(object sender, EventArgs e)
        {
            _singleInstanceForm = null;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (_multiInstanceForm == null)
            {
                _multiInstanceForm = new MultiInstance_MainForm();
                _multiInstanceForm.Disposed += new EventHandler(_multiInstanceForm_Disposed);
            }
            _multiInstanceForm.Show();
        }

        void _multiInstanceForm_Disposed(object sender, EventArgs e)
        {
            this._multiInstanceForm = null;
        }

        private void button3_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }
    }
}
